/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Logico;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author usuario
 */
@Entity
@Table(name = "disciplina")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Disciplina.findAll", query = "SELECT d FROM Disciplina d"),
    @NamedQuery(name = "Disciplina.findByIddisciplina", query = "SELECT d FROM Disciplina d WHERE d.iddisciplina = :iddisciplina"),
    @NamedQuery(name = "Disciplina.findByNombre", query = "SELECT d FROM Disciplina d WHERE d.nombre = :nombre"),
    @NamedQuery(name = "Disciplina.findByDescripcion", query = "SELECT d FROM Disciplina d WHERE d.descripcion = :descripcion"),
    @NamedQuery(name = "Disciplina.findByLogo", query = "SELECT d FROM Disciplina d WHERE d.logo = :logo")})
public class Disciplina implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @SequenceGenerator(name = "idDisciplina_generator", sequenceName = "disciplina_id_seq", allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "idDisciplina_generator")
    @Column(name = "iddisciplina")
    private Integer iddisciplina;
    @Column(name = "nombre")
    private String nombre;
    @Column(name = "descripcion")
    private String descripcion;
    @Column(name = "logo")
    private String logo;
    @ManyToMany(mappedBy = "disciplinaList")
    private List<Deportista> deportistaList;
    @JoinTable(name = "evento_disciplina", joinColumns = {
        @JoinColumn(name = "disciplina_iddisciplina", referencedColumnName = "iddisciplina")}, inverseJoinColumns = {
        @JoinColumn(name = "evento_idevento", referencedColumnName = "idevento")})
    @ManyToMany
    private List<Evento> eventoList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "disciplinaIddisciplina")
    private List<Competencia> competenciaList;

    public Disciplina() {
    }

    public Disciplina(Integer iddisciplina) {
        this.iddisciplina = iddisciplina;
    }

    public Integer getIddisciplina() {
        return iddisciplina;
    }

    public void setIddisciplina(Integer iddisciplina) {
        this.iddisciplina = iddisciplina;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public String getLogo() {
        return logo;
    }

    public void setLogo(String logo) {
        this.logo = logo;
    }

    @XmlTransient
    public List<Deportista> getDeportistaList() {
        return deportistaList;
    }

    public void setDeportistaList(List<Deportista> deportistaList) {
        this.deportistaList = deportistaList;
    }

    @XmlTransient
    public List<Evento> getEventoList() {
        return eventoList;
    }

    public void setEventoList(List<Evento> eventoList) {
        this.eventoList = eventoList;
    }

    @XmlTransient
    public List<Competencia> getCompetenciaList() {
        return competenciaList;
    }

    public void setCompetenciaList(List<Competencia> competenciaList) {
        this.competenciaList = competenciaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (iddisciplina != null ? iddisciplina.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Disciplina)) {
            return false;
        }
        Disciplina other = (Disciplina) object;
        if ((this.iddisciplina == null && other.iddisciplina != null) || (this.iddisciplina != null && !this.iddisciplina.equals(other.iddisciplina))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Logico.Disciplina[ iddisciplina=" + iddisciplina + " ]";
    }
    
}
